﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnnamedPodcastLibrary;

namespace PodcastLibrary
{
    class Program
    {
        static void Main(string[] args)
        {
            var podcasts = new PodcastData("state.xml");
            podcasts.Load();

            var feedUri = new Uri("http://thejamhole.com/?feed=podcast");
            podcasts.AddFeed(feedUri);

            var episodeDetails = FeedReader.ReadEpisodes(@"C:\Users\jeff\Documents\Visual Studio 2008\Projects\PodcastLibraryConsole\PodcastLibraryConsole\TheJamholeFeed.xml");
            var episodeUris = from episode in episodeDetails select episode.EpisodeUid;

            foreach (var newFeed in podcasts.GetNewEpisodeUids(feedUri, episodeUris))
            {
                Console.WriteLine(newFeed);
            }
        }

        void AddNewEpisodesAsDownloadedExceptFirst(PodcastData podcasts, Uri newFeed)
        {
            var episodes = FeedReader.ReadEpisodes(newFeed.OriginalString);
            foreach (var episode in episodes.Except<EpisodeDetails>(new[] { episodes.First<EpisodeDetails>() }))
            {
                podcasts.AddEpisode(episode.Source, episode.EpisodeUid);
            }
        }
    }
}
